<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:fb="http://www.facebook.com/2008/fbml">
	
	<script type="text/javascript"
		xmlns:fb="http://www.facebook.com/2008/fbml">
					
					function facebookLogin() {
						FB.getLoginStatus(function(response) {
							if (response.status === 'connected') {
								${remoteFunction(controller: "user", action: "facebookLogin", onSuccess: "showFacebookSignInModal()", update: [success: "facebookSigninModal"], options: '[asynchronous: true]')}
							}
						});
					}
					
					function showFacebookSignInModal() {
						$("#simpleLoginModal").modal('hide')
						$("#facebookSigninModal").modal('show')			
					}
	
					function facebookLogout() {
						//FB.logout(function(response) {
						//	user is now logged out
						//	});
					}
					
							function logoutSesionFB() {
			var url = window.location.href;
			FB.logout(function(response) {
				location.href = url;
			});
		}
	
					function logoutFacebook() {
						logoutSesionFB();
					}
	
					function hideFacebookUserName() {
						document.getElementById("usuario_facebook_2").style.display = 'none';
					}
					
					function setFacebookUsername(id) {
						FB.getLoginStatus(function(response) {

								if (response.status == 'connected') {
				
										FB.api(	{
											method: 'fql.query',
											query: 'SELECT first_name,last_name FROM user WHERE uid='+response.authResponse.userID
										},
				
										function(response) {
											var username = response[0].first_name + " " + response[0].last_name;
											$('#'+id).html(username);
										}
										);
								}
						});
					}
		</script>
	
    <!-- Modal panels. Render. Rendered only if the user is not logged -->
	<g:if test="${!session.user}">
		<div class="modal hide fade" id="simpleLoginModal">
			<g:render template="/user/simpleLogin" />
		</div>
		<div class="modal hide fade" id="siteSigninModal">
			<g:render template="/user/siteSignin" />
		</div>
		<div class="modal hide fade" id="facebookSigninModal"></div>
	</g:if>
	
	<!-- Header bar -->
	<div class="navbar navbar-inverse navbar-fixed-top">
		<div class="navbar-inner">
			<div class="container">
				<a class="btn btn-navbar" data-toggle="collapse"
					data-target=".nav-collapse"> <span class="icon-bar"></span> <span
					class="icon-bar"></span> <span class="icon-bar"></span>
				</a><g:link class="brand" url="/PhotoAdminGrailsApp"><g:message code="photo_admin.title" /></g:link>
				<div class="nav-collapse collapse">
				<ul class="nav">
					<li><g:link class="current" url="/PhotoAdminGrailsApp">Home</g:link></li>
					<li><a href="#about">About</a></li>
					<li><a href="#contact">Contact</a></li>
					<li class="dropdown"><a href="#" class="dropdown-toggle"
						data-toggle="dropdown">Dropdown <b class="caret"></b></a>
						<ul class="dropdown-menu">
							<li><a href="#">Action</a></li>
							<li><a href="#">Another action</a></li>
							<li><a href="#">Something else here</a></li>
							<li class="divider"></li>
							<li class="nav-header">Nav header</li>
							<li><a href="#">Separated link</a></li>
							<li><a href="#">One more separated link</a></li>
						</ul></li>
				</ul>

				<div class="navbar-form pull-right">
					<g:if test="${session.user}">
						<div class="btn-group">
							<button id="dropdownLoggedInUser" class="btn btn-success dropdown-toggle"
								data-toggle="dropdown">
								${session.user.username}
								<span class="caret"></span>
							</button>
							<ul class="dropdown-menu">
								<li><g:link controller="user" action="showProfile">
										<g:message code="user.profile.view" />
									</g:link></li>
								<li class="divider"></li>
								<li><g:link controller="user" action="logout">
										<g:message code="auth.logout" />
									</g:link></li>
							</ul>
						</div>
					</g:if>
					<g:else>
						<a id="enterSiteButton" data-toggle="modal" href="#simpleLoginModal"
							class="btn btn-success"><g:message code="auth.login" /></a>
					</g:else>
				</div>

			</div>
			</div>
		</div>
	</div>
</html>